home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 49
/
Aminet 49 (2002)(GTI - Schatztruhe)[!][Jun 2002].iso
/
Aminet
/
util
/
misc
/
ReportPlus.lha
/
ReportPlus
/
source
/
f11.c
< prev
next >
Wrap
C/C++ Source or Header
|
2002-04-15
|
20KB
|
553 lines
#include <exec/types.h>
#include <proto/exec.h>
#include <intuition/intuition.h>
#include <intuition/gadgetclass.h>
#include <proto/intuition.h>
#include <libraries/gadtools.h>
#include <proto/gadtools.h>
#define ALL_REACTION_CLASSES
#define ALL_REACTION_MACROS
#include <reaction/reaction.h>
#include <gadgets/texteditor.h>
#include <clib/texteditor_protos.h>
#include <pragmas/texteditor_pragmas.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "rp.h"
IMPORT struct AminetStruct aminet;
AGLOBAL struct AGDBStruct agdb;
AGLOBAL struct Gadget* agdb_gadgets[GIDS_11 + 1];
// from rp.c
IMPORT Object* WinObject[FUNCTIONS + 1];
IMPORT SBYTE page;
IMPORT struct Window* MainWindowPtr;
IMPORT struct SharedStruct shared;
IMPORT struct Screen* ScreenPtr;
IMPORT struct Menu* MenuPtr;
IMPORT ULONG offset,
signal;
IMPORT TEXT IOBuffer[LONGESTFIELD + 1],
aslresult[MEDFIELD + 1],
string[VLONGFIELD + 1];
IMPORT struct Library* TextEditorBase;
MODULE void updateagdbgadgets(void);
MODULE void readagdbgadgets(void);
AGLOBAL void agdb1(void)
{ struct Hook Hook11Struct;
if ((!(aminet.uploader[0])) && readin("S:Report.sender"))
{ /* # Refer: <last>,<first> (<company> ,phone <phone>)<LF>
# Path: <email><LF>
# ReferID: <developer><LF> */
offset = 0;
parse("# Refer: ");
parse(",");
parse(" (");
parse(" ,phone ");
parse(")\n# Path: ");
parse("\n# ReferID: ");
strcpy(aminet.uploader, string);
}
/* Create the window object. */
lockscreen();
gadtools();
InitHook(&Hook11Struct, Hook11Func, NULL);
if (!(WinObject[11] =
NewObject
(
WINDOW_GetClass(), NULL,
WA_PubScreen, ScreenPtr,
WA_ScreenTitle, "Report+",
WA_Title, "Report+: AGDB Review Editor",
WA_Activate, TRUE,
WA_DepthGadget, TRUE,
WA_DragBar, TRUE,
WA_CloseGadget, TRUE,
WA_SizeGadget, TRUE,
WA_IDCMP, IDCMP_RAWKEY,
WINDOW_IDCMPHook, &Hook11Struct,
WINDOW_IDCMPHookBits, IDCMP_RAWKEY,
WINDOW_MenuStrip, MenuPtr,
WINDOW_Position, WPOS_FULLSCREEN,
WINDOW_ParentGroup, agdb_gadgets[GID_11_LY1] =
NewObject
( LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_DeferLayout, TRUE,
LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_DeferLayout, TRUE,
LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_VertAlignment, LALIGN_CENTER,
LAYOUT_BevelStyle, BVS_NONE,
LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_HorizAlignment, LALIGN_RIGHT,
// LALIGN_RIGHT seems not to work, as you can see :-(
LAYOUT_BevelStyle, BVS_FIELD,
LAYOUT_AddImage, NewObject
( LABEL_GetClass(), NULL,
// label
LABEL_Text, "_Title:",
LABEL_Justification, LJ_RIGHT,
TAG_END
),
TAG_END
),
LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
// layout
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_HorizAlignment, LALIGN_RIGHT,
LAYOUT_BevelStyle, BVS_FIELD,
LAYOUT_AddImage, NewObject
( LABEL_GetClass(), NULL,
// label
LABEL_Text, "_Publisher (Year):",
LABEL_Justification, LJ_RIGHT,
TAG_END
),
TAG_END
),
LAYOUT_AddChild,
NewObject
( LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_HorizAlignment, LALIGN_RIGHT,
LAYOUT_BevelStyle, BVS_FIELD,
LAYOUT_AddImage, NewObject
( LABEL_GetClass(), NULL,
// label
LABEL_Text, "_Game Type:",
LABEL_Justification, LJ_RIGHT,
TAG_END
),
TAG_END
),
LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
// layout
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_HorizAlignment, LALIGN_RIGHT,
LAYOUT_BevelStyle, BVS_FIELD,
LAYOUT_AddImage, NewObject
( LABEL_GetClass(), NULL,
// label
LABEL_Text, "P_layers:",
LABEL_Justification, LJ_RIGHT,
TAG_END
),
TAG_END
),
LAYOUT_AddChild,
NewObject
( LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_HorizAlignment, LALIGN_RIGHT,
LAYOUT_BevelStyle, BVS_FIELD,
LAYOUT_AddImage, NewObject
( LABEL_GetClass(), NULL,
// label
LABEL_Text, "_Compatibility:",
LABEL_Justification, LJ_RIGHT,
TAG_END
),
TAG_END
),
LAYOUT_AddChild,
NewObject
( LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_HorizAlignment, LALIGN_RIGHT,
LAYOUT_BevelStyle, BVS_FIELD,
LAYOUT_AddImage, NewObject
( LABEL_GetClass(), NULL,
// label
LABEL_Text, "_HD Installable?",
LABEL_Justification, LJ_RIGHT,
TAG_END
),
TAG_END
),
LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
// layout
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_HorizAlignment, LALIGN_RIGHT,
LAYOUT_BevelStyle, BVS_FIELD,
LAYOUT_AddImage, NewObject
( LABEL_GetClass(), NULL,
// label
LABEL_Text, "_Submission:",
LABEL_Justification, LJ_RIGHT,
TAG_END
),
CHILD_WeightedWidth, 0,
TAG_END
),
TAG_END
),
CHILD_WeightedHeight, 0,
CHILD_WeightedWidth, 0,
LAYOUT_AddChild,
NewObject
( LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_VertAlignment, LALIGN_CENTER,
LAYOUT_HorizAlignment,LALIGN_CENTER,
LAYOUT_BevelStyle, BVS_FIELD,
LAYOUT_AddChild, agdb_gadgets[GID_11_ST1] =
NewObject(STRING_GetClass(), NULL,
// string
GA_ID, GID_11_ST1,
STRINGA_TextVal, agdb.title,
STRINGA_MinVisible, 20,
TAG_END),
LAYOUT_AddChild, agdb_gadgets[GID_11_ST2] =
NewObject(STRING_GetClass(), NULL,
// string
GA_ID, GID_11_ST2,
STRINGA_TextVal, agdb.publisher,
STRINGA_MinVisible, 20,
TAG_END),
LAYOUT_AddChild, agdb_gadgets[GID_11_ST3] =
NewObject(STRING_GetClass(), NULL,
// string
GA_ID, GID_11_ST3,
STRINGA_TextVal, agdb.gametype,
STRINGA_MinVisible, 20,
TAG_END),
LAYOUT_AddChild, agdb_gadgets[GID_11_ST4] =
NewObject(STRING_GetClass(), NULL,
// string
GA_ID, GID_11_ST4,
STRINGA_TextVal, agdb.players,
STRINGA_MinVisible, 20,
TAG_END),
LAYOUT_AddChild, agdb_gadgets[GID_11_ST5] =
NewObject(STRING_GetClass(), NULL,
// string
GA_ID, GID_11_ST5,
STRINGA_TextVal, agdb.hdinstallable,
STRINGA_MinVisible, 20,
TAG_END),
LAYOUT_AddChild, agdb_gadgets[GID_11_ST6] =
NewObject(STRING_GetClass(), NULL,
// string
GA_ID, GID_11_ST6,
STRINGA_TextVal, agdb.compatibility,
STRINGA_MinVisible, 20,
TAG_END),
LAYOUT_AddChild, agdb_gadgets[GID_11_ST7] =
NewObject(STRING_GetClass(), NULL,
// string
GA_ID, GID_11_ST7,
STRINGA_TextVal, aminet.uploader,
STRINGA_MinVisible, 20,
TAG_END),
CHILD_WeightedHeight, 0,
TAG_END
),
CHILD_WeightedHeight, 0,
TAG_END
),
CHILD_WeightedHeight, 0,
LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
// layout
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_HorizAlignment,LALIGN_CENTER,
LAYOUT_BevelStyle, BVS_FIELD,
LAYOUT_AddImage, NewObject
( LABEL_GetClass(), NULL,
// label
LABEL_Text, "_Review:",
LABEL_Justification, LJ_CENTER,
TAG_END
),
TAG_END
),
CHILD_WeightedHeight, 0,
LAYOUT_AddChild, agdb_gadgets[GID_11_TE1] =
(struct Gadget *) NewObject
( TEXTEDITOR_GetClass(), NULL,
GA_ID, GID_11_TE1,
GA_RelVerify, TRUE,
GA_TEXTEDITOR_ExportWrap, 75,
TAG_END
),
TAG_END
),
TAG_END
)))
{ rq("Can't create ReAction gadgets!");
}
unlockscreen();
openwindow();
SetGadgetAttrs
( agdb_gadgets[GID_11_TE1], MainWindowPtr, NULL,
GA_TEXTEDITOR_Contents, agdb.textfield
); // long description
OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_NEW, NOSUB));
OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_OPEN, NOSUB));
OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVE, NOSUB));
OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVEAS, NOSUB));
ActivateLayoutGadget(agdb_gadgets[GID_11_LY1], MainWindowPtr, NULL, (Object) agdb_gadgets[GID_11_ST1]);
loop();
readagdbgadgets();
closewindow();
}
AGLOBAL void saveagdb(ABOOL saveas)
{ /* Title <title>
Publisher <publisher>
Game Type <game type>
Players <players>
HD Installable <hd installable>
Compatibility <compatibility>
Submission <uploader>
Review
<review> */
readagdbgadgets();
strcpy(IOBuffer, "Title: ");
strcat(IOBuffer, agdb.title);
strcat(IOBuffer, "\nPublisher: ");
strcat(IOBuffer, agdb.publisher);
strcat(IOBuffer, "\nGame Type: ");
strcat(IOBuffer, agdb.gametype);
strcat(IOBuffer, "\nPlayers: ");
strcat(IOBuffer, agdb.players);
strcat(IOBuffer, "\nHD Installable: ");
strcat(IOBuffer, agdb.hdinstallable);
strcat(IOBuffer, "\nCompatibility: ");
strcat(IOBuffer, agdb.compatibility);
strcat(IOBuffer, "\nSubmission: ");
strcat(IOBuffer, aminet.uploader);
strcat(IOBuffer, "\n\nReview:\n");
strcat(IOBuffer, agdb.textfield);
if (!agdb.output[0] || saveas) // if we need a filename
{ if (saveasl("Save AGDB Review", "~(#?.info)"))
{ strcpy(agdb.output, aslresult);
writeout(agdb.output);
} }
else
{ writeout(agdb.output);
} }
AGLOBAL void agdb_loop(ULONG gid)
{ ; // :-)
}
AGLOBAL ULONG Hook11Func(struct Hook *h, VOID *o, VOID *msg)
{ /* "When the hook is called, the data argument points to the
window object and message argument to the IntuiMessage." */
UWORD code, qual;
geta4(); // wait till here before doing anything
code = ((struct IntuiMessage *) msg)->Code;
qual = ((struct IntuiMessage *) msg)->Qualifier;
switch(code)
{
case SCAN_HELP:
helpabout();
break;
case SCAN_ESCAPE:
if ((qual & IEQUALIFIER_LSHIFT) || (qual & IEQUALIFIER_RSHIFT))
{ cleanexit(EXIT_SUCCESS);
} else page = 0;
break;
case SCAN_T:
ActivateLayoutGadget(agdb_gadgets[GID_11_LY1], MainWindowPtr, NULL, (Object) agdb_gadgets[GID_11_ST1]);
break;
case SCAN_P:
ActivateLayoutGadget(agdb_gadgets[GID_11_LY1], MainWindowPtr, NULL, (Object) agdb_gadgets[GID_11_ST2]);
break;
case SCAN_G:
ActivateLayoutGadget(agdb_gadgets[GID_11_LY1], MainWindowPtr, NULL, (Object) agdb_gadgets[GID_11_ST3]);
break;
case SCAN_L:
ActivateLayoutGadget(agdb_gadgets[GID_11_LY1], MainWindowPtr, NULL, (Object) agdb_gadgets[GID_11_ST4]);
break;
case SCAN_C:
ActivateLayoutGadget(agdb_gadgets[GID_11_LY1], MainWindowPtr, NULL, (Object) agdb_gadgets[GID_11_ST5]);
break;
case SCAN_H:
ActivateLayoutGadget(agdb_gadgets[GID_11_LY1], MainWindowPtr, NULL, (Object) agdb_gadgets[GID_11_ST6]);
break;
case SCAN_S:
ActivateLayoutGadget(agdb_gadgets[GID_11_LY1], MainWindowPtr, NULL, (Object) agdb_gadgets[GID_11_ST7]);
break;
case SCAN_R:
ActivateLayoutGadget(agdb_gadgets[GID_11_LY1], MainWindowPtr, NULL, (Object) agdb_gadgets[GID_11_TE1]);
break;
default:
break;
}
return(1);
}
AGLOBAL void newagdb(ABOOL display)
{ strcpy(agdb.title, "");
strcpy(agdb.publisher, "");
strcpy(agdb.gametype, "");
strcpy(agdb.players, "");
strcpy(agdb.hdinstallable, "");
strcpy(agdb.compatibility, "");
strcpy(aminet.uploader, "");
strcpy(agdb.output, "");
strcpy(agdb.textfield, "");
if (display)
updateagdbgadgets();
}
AGLOBAL void openagdb(void)
{ if (asl("~(#?.info)"))
{ strcpy(agdb.output, aslresult);
loadagdb();
updateagdbgadgets();
} }
AGLOBAL void loadagdb(void)
{ if (readin(agdb.output))
{ offset = 0;
parse("Title: ");
parse("\nPublisher: ");
strcpy(agdb.title, string);
parse("\nGame Type: ");
strcpy(agdb.publisher, string);
parse("\nPlayers: ");
strcpy(agdb.gametype, string);
parse("\nHD Installable: ");
strcpy(agdb.players, string);
parse("\nCompatibility: ");
strcpy(agdb.hdinstallable, string);
parse("\nSubmission: ");
strcpy(agdb.compatibility, string);
parse("\n\nReview:\n");
strcpy(aminet.uploader, string);
parsetoend();
strcpy(agdb.textfield, string);
updateagdbgadgets();
} }
MODULE void updateagdbgadgets(void)
{ SetGadgetAttrs
( agdb_gadgets[GID_11_ST1], MainWindowPtr, NULL,
STRINGA_TextVal, agdb.title,
TAG_DONE
);
SetGadgetAttrs
( agdb_gadgets[GID_11_ST2], MainWindowPtr, NULL,
STRINGA_TextVal, agdb.publisher,
TAG_DONE
);
SetGadgetAttrs
( agdb_gadgets[GID_11_ST3], MainWindowPtr, NULL,
STRINGA_TextVal, agdb.gametype,
TAG_DONE
);
SetGadgetAttrs
( agdb_gadgets[GID_11_ST4], MainWindowPtr, NULL,
STRINGA_TextVal, agdb.players,
TAG_DONE
);
SetGadgetAttrs
( agdb_gadgets[GID_11_ST5], MainWindowPtr, NULL,
STRINGA_TextVal, agdb.hdinstallable,
TAG_DONE
);
SetGadgetAttrs
( agdb_gadgets[GID_11_ST6], MainWindowPtr, NULL,
STRINGA_TextVal, agdb.compatibility,
TAG_DONE
);
SetGadgetAttrs
( agdb_gadgets[GID_11_ST7], MainWindowPtr, NULL,
STRINGA_TextVal, aminet.uploader,
TAG_DONE
);
SetGadgetAttrs
( agdb_gadgets[GID_11_TE1], MainWindowPtr, NULL,
GA_TEXTEDITOR_Contents, aminet.textfield,
TAG_DONE
);
}
MODULE void readagdbgadgets(void)
{ STRPTR textBuffer;
if (!(GetAttr
( STRINGA_TextVal, agdb_gadgets[GID_11_ST1], (ULONG *) agdb.title
)))
{ rq("Unsupported inquiry!"); // should never happen
}
if (!(GetAttr
( STRINGA_TextVal, agdb_gadgets[GID_11_ST2], (ULONG *) agdb.publisher
)))
{ rq("Unsupported inquiry!"); // should never happen
}
if (!(GetAttr
( STRINGA_TextVal, agdb_gadgets[GID_11_ST3], (ULONG *) agdb.gametype
)))
{ rq("Unsupported inquiry!"); // should never happen
}
if (!(GetAttr
( STRINGA_TextVal, agdb_gadgets[GID_11_ST4], (ULONG *) agdb.players
)))
{ rq("Unsupported inquiry!"); // should never happen
}
if (!(GetAttr
( STRINGA_TextVal, agdb_gadgets[GID_11_ST5], (ULONG *) agdb.hdinstallable
)))
{ rq("Unsupported inquiry!"); // should never happen
}
if (!(GetAttr
( STRINGA_TextVal, agdb_gadgets[GID_11_ST6], (ULONG *) agdb.compatibility
)))
{ rq("Unsupported inquiry!"); // should never happen
}
if (!(GetAttr
( STRINGA_TextVal, agdb_gadgets[GID_11_ST7], (ULONG *) aminet.uploader
)))
{ rq("Unsupported inquiry!"); // should never happen
}
textBuffer = (STRPTR) DoGadgetMethod(agdb_gadgets[GID_11_TE1], MainWindowPtr, NULL, GM_TEXTEDITOR_ExportText, NULL);
strcpy(agdb.textfield, textBuffer); // long description
FreeVec((APTR) textBuffer);
// textBuffer = NULL;
}